package com.etao.tools.service;

import com.etao.tools.Iservice.ITurnOverService;
import com.etao.tools.common.ExportExcel;
import com.etao.tools.common.PropertyUtils;
import com.etao.tools.common.email.EmailUtil;
import com.etao.tools.dao.TurnOverDao;
import com.etao.tools.entity.TurnOverListByDayEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by lyp on 2016/8/11.
 */
@Service
public class TurnOverService implements ITurnOverService {
@Autowired
private TurnOverDao turnOverDao;

  public  List<TurnOverListByDayEntity> TurnOverListByDay()
    {
        return turnOverDao.TurnOverListByDay();
    }

    public void TurnOverAndSendEmail()
    {
        String dateNow = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前日期

        ExportExcel excel = ExportExcel.getInstance();
        List<TurnOverListByDayEntity> turnOverListByDay = turnOverDao.TurnOverListByDay();

        excel.AddTurnOverListByDaySheet(turnOverListByDay);

        ExportExcel.Export("门店日营业额.xls");
        EmailUtil.sendEmail("每日统计数据","Hello All: 请查收附件~",
                PropertyUtils.getProperty("ecb.mail.to").split(";"), "门店日营业额.xls");
    }
}
